package com.qfedu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.entity.Depart;
import com.qfedu.entity.ResponseData;
import com.qfedu.entity.Staff;
import com.qfedu.entity.User;
import com.qfedu.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/staff")
public class StaffController {

    @Autowired
    private StaffService staffService;

    @RequestMapping("/queryStaff.do")
    public ResponseData queryStaff(HttpServletRequest request) {

        // 获取已经登录的no
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");

        String no = user.getNo();


        Staff staff = staffService.findStaffByNo(no);

        ResponseData<Object> responseData = new ResponseData<>();
        responseData.setCode(0);
        responseData.setCount(1);
        responseData.setMsg("staff信息");
        responseData.setData(staff);

        return responseData;
    }

}
